package com.jhws.business.comm.controller;

import com.jhws.common.base.bo.JsonRespData;
import com.jhws.business.comm.bo.RoomTypeGroup;
import com.jhws.business.comm.service.RoomTypeGroupService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("/RoomTypeGroupCtrl")
public class RoomTypeGroupCtrl {
    @Resource
    private RoomTypeGroupService roomTypeGroupService;

    /**
     * 保存户型组信息
     *
     * @param roomTypeGroup 户型组信息
     */
    @RequestMapping("saveRoomTypeGroup.x")
    @ResponseBody
    public JsonRespData saveRoomType(RoomTypeGroup roomTypeGroup) throws Exception {
        roomTypeGroupService.saveRoomTypeGroup(roomTypeGroup);
        return new JsonRespData("", 1, "保存成功");
    }

    /**
     * 查询户型组信息
     *
     * @param id 户型组信息ID
     */
    @RequestMapping("queryRoomTypeGroup.x")
    @ResponseBody
    public JsonRespData queryRoomType(Long id) {
        return new JsonRespData("", 1, roomTypeGroupService.queryRoomTypeGroup(id));
    }

    /**
     * 条件查询户型组信息列表
     */
    @RequestMapping("queryRoomTypesGroup.x")
    @ResponseBody
    public JsonRespData queryRoomTypeGroups(String commCode) {
        String where = "where comm_code='" + commCode + "'";
        return new JsonRespData("", 1, roomTypeGroupService.queryRoomTypeGroups(where));
    }

    /**
     * 分页查询户型组信息列表
     *
     * @param param 条件
     */
    @RequestMapping("queryRoomTypePageGroup.x")
    @ResponseBody
    public JsonRespData queryRoomTypePage(@RequestParam Map param) {
        return new JsonRespData("", 1, roomTypeGroupService.queryRoomTypeGroupPage(param));
    }

    /**
     * 删除户型信息
     *
     * @param roomTypeGroup 户型组信息ID
     */
    @RequestMapping("deleteRoomTypeGroup.x")
    @ResponseBody
    public JsonRespData deleteRoomType(RoomTypeGroup roomTypeGroup) {
        roomTypeGroupService.deleteRoomTypeGroup(roomTypeGroup);
        return new JsonRespData("", 1, "删除成功");
    }
}
